package com.yj.web;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import com.alibaba.fastjson.JSON;
import com.yj.util.UpLoad;

@RestController
public class UpLoadController {

	
	@RequestMapping("/upload")
	public String test1(@RequestParam("file") MultipartFile file) {
		System.out.println(UpLoad.upload(file));
		return "index";
	}
	
	@RequestMapping("/multiUpload")
	public String test1(HttpServletRequest request) {
		List<MultipartFile> files = ((MultipartHttpServletRequest) request).getFiles("file");
		String multiUpload = UpLoad.multiUpload(files);
		Object parse = JSON.parse(multiUpload);
		System.out.println(parse);
		return multiUpload;
	}
	
}
